<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<!DOCTYPE html>
<head>
    <meta charset="utf-8">
    <title>用户注册...</title>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="icon" href="../static/img/logo.png">
    <script src="../static/js/extra/jquery-3.4.1.min.js"></script>
    <link rel="stylesheet" href="../static/css/login.css" media="all">
</head>
<body>
<div class="htmleaf-container">
    <div class="wrapper">
        <div class="container">
            <div class="layui-form">
                <form class="loginForm" id="resisterForm" lay-filter="resisterForm">
                    <input name="accountNumber" type="text" placeholder="账号" lay-verify="required">
                    <input name="pwd" type="password" placeholder="密码(4-16位字母+数字)" lay-verify="required">
                    <input name="name" type="text" placeholder="姓名" lay-verify="required">
                    <input name="phone" type="text" placeholder="手机" lay-verify="phone">
                    <button lay-submit lay-filter="resisterForm">注册</button>
                    <br><a href="user/toLogin">已有帐号</a>
                    <br><br>
                </form>
            </div>
        </div>
        <ul class="bg-bubbles">
            <li></li>
            <li></li>
            <li></li>
            <li></li>
            <li></li>
            <li></li>
            <li></li>
            <li></li>
            <li></li>
            <li></li>
        </ul>

    </div>
</div>
<div style="text-align:center;margin:50px 0; font:normal 14px/24px 'MicroSoft YaHei';color:#000000">
    <h1>生鲜超市销售管理系统</h1>
</div>
<script src="../static/layui/layui.js"></script>
<script>
    layui.use(['form'], function () {
        let $ = layui.$,
            form = layui.form;
        form.render();
        //提交
        form.on('submit(resisterForm)', function (obj) {
            let field = obj.field;
            $.ajax({
                url: 'register',
                type: "post",
                dataType: "json",
                contentType: 'application/x-www-form-urlencoded',
                data: $('#resisterForm').serializeArray(),
                async: false,
                success: function (result) {
                    if (result.code === true) {
                        window.location.href = "toLogin";
                    } else {
                        layer.msg(result.msg);
                    }
                },
            });

            return false;
        });
    });
</script>
</body>